package com.maowei.event;

/**
 * 事件处理上下文对象 -- 策略模式
 *
 * @author maowei
 * @date 2021/8/24
 */
public class EventHandleContext {

    /**
     * 事件处理器
     */
    private IEventHandler handler;
    /**
     * 事件信息
     */
    private EventInfo eventInfo;

    public EventHandleContext(IEventHandler handler, EventInfo eventInfo) {
        this.handler = handler;
        this.eventInfo = eventInfo;
    }

    public void setHandler(IEventHandler handler) {
        this.handler = handler;
    }

    public void handle() {
        handler.handle(eventInfo);
    }
}
